package resources;


import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;

import com.google.common.io.Files;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;


/**
 *
 * @author Einsiedler
 */
public class Screenshot {
    
    public Screenshot(){
        
    }
    /**
     * Method for generation screen shots
     */
    public void getscreenshot(WebDriver driver, String namemethod){
        File screenshot = new File("./screenshots/"+namemethod);
        File screenshotTempFile = ((TakesScreenshot) driver).
                getScreenshotAs(OutputType.FILE);
        try {
            Files.copy(screenshotTempFile, screenshot);
        } catch (IOException ex) {
            Logger.getLogger(Screenshot.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    

}
